# _*_ coding: utf-8 _*_
from PyQt5 import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtGui


class CustomMenuBar(QtWidgets.QMenuBar):
    '''自定义菜单'''
    menu = None
    official = None
    quit = None
    def __init__(self, url=None, parent=None):
        super(CustomMenuBar, self).__init__(parent)
        self.url = url
        self.initMenu()


    def openOfficial(self) -> None:
        '''打开官方'''
        QtGui.QDesktopServices.openUrl(QtCore.QUrl(self.url))


    def initMenu(self) -> None:
        '''初始化菜单'''
        self.menu = self.addMenu("&菜单")
        # 官方
        self.official = QtWidgets.QAction("官方")
        self.official.setShortcut("Ctrl+O")
        self.official.triggered.connect(self.openOfficial)

        # 退出
        self.quit = QtWidgets.QAction("退出")
        self.quit.setShortcut("Ctrl+Q")
        self.quit.triggered.connect(QtWidgets.qApp.quit)

        # 添加Actions
        self.menu.addAction(self.official)
        self.menu.addAction(self.quit)
